package com.company;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Class001 {
    private static final Logger logger = LoggerFactory.getLogger("服务端");

    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(9988);
        logger.trace("服务端程序已经启动");


        Socket server = serverSocket.accept();
        logger.trace(server.getInetAddress().getHostAddress() + "客户端已连接成功");

        InputStream inputStream = server.getInputStream();

        byte[] buf = new byte[1024];
        int len = inputStream.read(buf);
        String msg = new String(buf, 0, len);
        logger.trace("客户端发送的消息" + msg);
        OutputStream outputStream = server.getOutputStream();
        outputStream.write("我不好".getBytes());
        serverSocket.close();
        server.close();
        outputStream.close();
        inputStream.close();

    }
}
